# $Id: Makefile 15 2009-01-19 02:21:28Z vic.fryzel $

NAME = Fryzel
DOC = ../doc

all: interpreter_build compiler_build
	
interpreter_build: parser_build
	cd interpreter; make all; cd ..

compiler_build: parser_build
	cd compiler; make all; cd ..

parser_build:
	cd parser; make all; cd ..
	
dist: distreq Parser_$(NAME).jar Interpreter_$(NAME).jar Compiler_$(NAME).jar

distreq:
	cd $(DOC); make doc; cd ../src
	cp -R $(DOC) .

Parser_$(NAME).jar: all
	jar cfe $@ parser.Parser *

Interpreter_$(NAME).jar: all
	jar cfe $@ interpreter.Interpreter *

Compiler_$(NAME).jar: all
	jar cfe $@ compiler.Compiler *

clean:
	cd parser; make clean; cd ..
	cd interpreter; make clean; cd ..
	cd compiler; make clean; cd ..
	rm -Rf *.jar pj2* META-INF doc *.tmp

# Everything after this line is a work in progress.  Trying to build parser
# from pj2 grammar file.
Parser.java: # pj2
	if [ ! -e Parser.java ]; then \
		java -classpath $(CLASSPATH) -jar pj2.jar -Generate grammar.pj2 > Parser.tmp; \
		java -classpath $(CLASSPATH) -jar jay.jar Parser.tmp > Parser.java; \
	fi

jlex:
	if [ ! -e jlex-1.2.6.jar ]; then \
		wget -N http://www.cs.rit.edu/~ats/projects/lp2/wcs/JLex/jlex-1.2.6.jar; \
        fi

jay:
	if [ ! -e jay.jar ]; then \
		wget -N http://www.cs.rit.edu/~ats/projects/lp/doc/jay/doc-files/jay.jar; \
	fi
